<!DOCTYPE html>
<?php session_start(); ?>
<html>
	<head>
		<title>ShowBooks</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="index.css" type="text/css" rel="stylesheet" media="screen" />
		<link href="css/usercontrol.css" type="text/css" rel="stylesheet" media="screen" />
	</head>
	<body>
		<?php
		if(!isset($_SESSION["session_username"]))
		{
			header("location:index.php");
			exit();
		}
		if(!isset($_SESSION["session_admin"])|| ($_SESSION["session_admin"]!=true))
		{
			// echo "admin";
			header("location:index.php");
			exit();
		}
		$logname = $_SESSION["session_username"];
		?>
		<div class="topbar">
			<div class="loginfo">
				<ul>
					<li>
						<?=$logname?>
						<input type="button" value="用户管理" onclick="window.location.href ='UserControl.php'"/>
						<input type="button" value="注销" onclick="window.location.href ='Logout.php'"/>
					</li>
				</ul>
			</div>
			<div class="globalitems">
				<ul>
					<li>
						<a href="index.php">首页</a>
					</li>
					<li>
						<a href="SearchBook.php?allbook=true">书库</a>
					</li>
					<li>
						<a href="showGroup.php">我的群组</a>
						</li>
						<li>
							<a href="index.php">随便看看</a>
						</li>
					</ul>
				</div>
			</div>
	</body>
	<div id="main">
		<div class="manage">
	<fieldset>
	<legend>所有用户</legend>
	<?php
		include_once 'User.php';
		$userlist = NormalUser::getAllNormalUser();
		for($count = 0;$count < count($userlist);$count ++)
		{
			$name = $userlist[$count]->getName();
	?>
		<div class="control">
			<span><?=$name?></span>
			<form action="DeleteUser.php" method="post">
				<input type="hidden" name="delUname" value="<?=$name?>"/>
				<input type="submit" value="删除用户" />
			</form>
		</div>
	<?php
		}
	?>
	</fieldset>
</div>
	
	<div class="manage">
	<fieldset>
	<legend>所有群组</legend>
	<?php
		include_once 'Group.php';
		$grouplist = NormalGroup::getAllGroup();
		for($count = 0;$count < count($grouplist);$count ++)
		{
			
	?>
		<div class="control">
			<span><?=$grouplist[$count]?></span>
			<form action="DeleteGroup.php" method="post">
				<input type="hidden" name="delGname" value="<?=$grouplist[$count]?>"/>
				<input type="submit" value="删除群组" />
			</form>
		</div>
	<?php
		}
	?>
	</fieldset>
</div>
	
	<div class="manage">
	<fieldset>
		<legend>所有图书</legend>
		<?php
			include_once 'Book.php';
			$booklist = Book::findBookLikeName(null);
			for($count = 0;$count < count($booklist);$count ++)
			{
				$dbname = $booklist[$count]->getName();
		?>
			<div class="control">
				<span><?=$dbname?></span>
				<form action="DeleteBook.php" method="post">
					<input type="hidden" name="delBname" value="<?=$dbname?>"/>
					<input type="submit" value="删除图书" />
				</form>
			</div>
		<?php
			}
		?>
	</fieldset>
</div>
</div>
</html>